import Singleton from '../Base/Singleton'
import { ILevel, ITile } from '../Levels'
import { TileManager } from '../Scripts/Tile/TileManager'
import { PlayerManager } from '../Scripts/Player/PlayerManager'
import { DoorManager } from '../Scripts/Door/DoorManager'
import { EnemyManager } from '../Base/EnemyManager'
import { BurstManager } from '../Scripts/Burst/BurstManager'
import { SpikesManager } from '../Scripts/Spikes/SpikesManager'
import { SmokeManager } from '../Scripts/Smoke/SmokeManager'

export type IRecord = Omit<ILevel, 'mapInfo'>

/**
 * 单例模式
 * 当前渲染的地图数据
 */
export default class DataManager extends Singleton {
  static get Instance() {
    return super.GetInstance<DataManager>()
  }
  mapInfo: Array<Array<ITile>> = [] // 地图数据
  tileInfo: Array<Array<TileManager>> //当前位置信息，当前位置类型，是否可走可转
  mapRowCount: number = 0 //行数
  mapColumnCount: number = 0 //列数
  levelIndex: number = 1 // 当前关卡
  player: PlayerManager // 当前人物信息
  enemies: EnemyManager[] // NPC信息
  door: DoorManager
  bursts: BurstManager[] //地裂
  spikes: SpikesManager[] //地刺
  smokes: SmokeManager[] //烟雾
  records: IRecord[] //操作步骤，便于撤回
  reset() {
    this.mapInfo = []
    this.tileInfo = []
    this.mapColumnCount = 0
    this.mapRowCount = 0
    this.player = null
    this.enemies = []
    this.door = null
    this.bursts = []
    this.spikes = []
    this.smokes = []
    this.records = []
  }
}
